package com.renrenyou.duanshipin.base;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.viewbinding.ViewBinding;

import com.renrenyou.duanshipin.R;

public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActivity {

    public T mBinding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        // 设置浅色状态栏文字 (深色背景)
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            getWindow().getDecorView().setSystemUiVisibility(
                    View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
            );
        }
        super.onCreate(savedInstanceState);
        if (mBinding == null) {
            mBinding = getBinding(getLayoutInflater());
            mBinding.getRoot().setFitsSystemWindows(true);
            setContentView(mBinding.getRoot());
        }
    }

    abstract public T getBinding(LayoutInflater inflater);
}
